package example

import (
	"code.google.com/p/go-glue/rlglue"
	"fmt"
	"math/rand"
)

type Environment int

func (re Environment) EnvInit() (taskString string) {
	format := "VERSION RL-Glue-3.0 PROBLEMTYPE episodic DISCOUNTFACTOR 1 OBSERVATIONS INTS (0 %d) ACTIONS INTS (0 1) REWARDS (0 1.0)"
	tstr := fmt.Sprintf(format, re-1)
	return tstr
}
func (re Environment) EnvStart() (obs rlglue.Observation) {
	return rlglue.NewObservation([]int32{rand.Int31n(int32(re))}, []float64{}, []byte{})
}
func (re Environment) EnvStep(action rlglue.Action) (obs rlglue.Observation, r float64, t bool) {
	obs = rlglue.NewObservation([]int32{rand.Int31n(int32(re))}, []float64{}, []byte{})
	r = -1
	t = rand.Intn(2) == 1
	return
}
func (re Environment) EnvCleanup() {
}
func (re Environment) EnvMessage(message string) (reply string) {
	return ""
}
